package com.example.controller;

import com.alibaba.csp.sentinel.slots.block.BlockException;

import com.example.entity.Product;
import org.springframework.http.ResponseEntity;

public class MyBlockHandler {


    //自定义限流处理方法
    public static String helloBlockHandler(BlockException ex) {
        ex.printStackTrace();
        return "这是hello的限流处理";
    }

    public static ResponseEntity<Product> findProductByIdBlockHandler(Integer id,
                                                               BlockException ex){
        Product product = new Product();
        product.setId(-1);
        product.setName("限流处理的商品");
        return ResponseEntity.ok(product);
    }

}
